home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / help_sz / static < prev    next >
Text File  |  1994-09-21  |  1KB  |  39 lines

  1. static:
  2.  
  3. Syntax:    static ( VAR1 , VAR2 , VAR3, ... )
  4.  
  5. Description:
  6.  
  7.     The static declaration is used to protect the specified
  8.     variables within the scope of a file. There are no
  9.     restrictions on where or how many static declarations can
  10.     occur. Static declarations only affect statements after the
  11.     declaration. Static variables are not visible to statements or
  12.     functions outside of the file in which they are created.
  13.  
  14.     Since all input to RLaB is treated as originating from a file
  15.     (stdin, for example), static variables can be used from the
  16.     command line to protect variables from functions if
  17.     necessary. For example:
  18.  
  19.     > // From the command line
  20.     > static (pi)
  21.     > pi = 12;
  22.     > load ("./jnk.r");
  23.     > system ("cat jnk.r");
  24.     x = function ( )
  25.     {
  26.       global (pi)
  27.       pi = -atan(1.0)*4;
  28.     };
  29.     > x();
  30.     > pi
  31.      pi =
  32.            12
  33.  
  34.     As you can see `pi' is declared global within the function
  35.     `x'. In spite of the global declaration, `x', because it was
  36.     created from within another file, cannot modify `pi'.
  37.  
  38. See Also: FUNCTION, global, local
  39.